<template>
    <div>
        <!-- 表头 -->
        <el-page-header @back="goBack" content="基本配置表单" title="返回">
        </el-page-header>
        <!-- 表单 -->
        <div>
            {{this.form}}
            <el-form ref="form" :model="form" label-width="80px" size="small">
                <el-form-item label="名字" >
                    <el-input v-model="form.name"></el-input>
                </el-form-item>
                <el-form-item label="值" >
                    <el-input v-model="form.val"></el-input>
                </el-form-item>
                <el-form-item label="介绍">
                    <el-input v-model="form.introduce"></el-input>
                </el-form-item>
            </el-form>
        </div>
        <div style="text-align:right">
            <el-row>
                <el-button type="primary" plain size="small" @click="submitForm()">提交</el-button>
            </el-row>
        </div>
    </div>
</template>

<script>
import {post} from '@/utils/request'
export default {
    data () {
        return {
            form:{}
        }
    },
    methods: {
        // 提交
        submitForm(){
            // 1`把要提交的数据传到后台接口saveOrUpdate
            let url="http://localhost:8888/baseconfig/saveOrUpdate"
            post(url,this.form).then(rqst=>{
                this.$message({type:"success",message:rqst.message})
            })
            // 2`返回到列表首页----调用goBack()
            this.goBack();
        },
        // 返回上一页(返回上一页的时候上一页的数据会自动加载)
        goBack() {
            this.$router.go(-1);
        }
    },
    created () {
        // 获取页面A中路由的数据
        this.form=this.$route.query
    }
}
</script>

<style lang="sass" scoped>

</style>


